package com.yzc.mihuyou.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yzc.mihuyou.entity.Attention;
import com.yzc.mihuyou.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 郭权文
 * @since 2022-05-06
 */
@Mapper
public interface AttentionMapper extends BaseMapper<Attention> {
    @Select("SELECT a.id,a.state,user_id,img.user_image,user_nikname,user_individuality\n" +
            "from user as u\n" +
            "JOIN attention as a\n" +
            "ON a.Aid = u.user_id\n" +
            "JOIN userimg as img\n" +
            "on img.image_id = a.Aid\n" +
            "WHERE a.Uid = ${id} and a.state =1\n")
    public List<User> getAttention(Long id);

    @Select("SELECT a.id,a.state,user_id,img.user_image,user_nikname,user_individuality\n" +
            "from user as u\n" +
            "JOIN attention as a\n" +
            "ON a.Uid = u.user_id\n" +
            "JOIN userimg as img\n" +
            "on img.image_id = a.Uid\n" +
            "WHERE a.Aid = ${id} and a.state =1\n")
    public List<User> getFans(Long id);
}
